<template>
    <div style="text-align: center;">
        <h1>登录</h1>
        <table class="table-bordered" align="center" style="width: 300px;" >
            <tbody>
                <tr>
                <td>账号</td>
                <td>
                    <input type="text" v-model="data.name" style="border:0" placeholder="请输入账号">
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td>
                    <input type="password" v-model="data.pass"style="border:0">
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="button" value="登录" class="btn btn-success" @click="logins">
                </td>
            </tr>
            </tbody>
           
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const data=ref({
    name:"",
    pass:""
})

const logins=()=>{
    if(data.value.name==""){
        alert('账号不能为空')
        return;
    }
    if(data.value.pass==""){
        alert('密码不能为空')
        return;
    }
    axios.get("https://localhost:7041/api/Men/Login",{params:data.value}).then(res=>{
        if(res.data==1){
            alert('账号错误')
        }
        if(res.data==2){
            alert('密码错误')
        }
        if(res.data==3){
            alert('登录成功')
        }
    })
}
</script>

<style scoped>

</style>